package com.jse.awt.screen;

import org.junit.Test;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

/**
 * @author : zenghua
 * @version : v0.1 CaptureScreenTest.java
 * @since : 2017/10/16 13:18
 */
public class CaptureScreenTest {


	/**
	 * 参考地址：20个非常有用的Java程序片段：http://www.iteye.com/news/32708
	 * @throws Exception
	 */
	@Test
	public void testSimple() throws Exception {
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		Rectangle screenRectangle = new Rectangle(screenSize);
		Robot robot = new Robot();
		BufferedImage image = robot.createScreenCapture(screenRectangle);
		ImageIO.write(image, "png", new File("C:\\keystore.png"));

		Thread.sleep(5000);
	}
}
